home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp4.arc / SENDFUNK.PAS < prev    next >
Pascal/Delphi Source File  |  1985-09-05  |  4KB  |  86 lines

  1. (*----------------------------------------------------------------------*)
  2. (*       Send_Function_Key  --- Send function key definition            *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Send_Function_Key( Key_Text : AnyStr ) ;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*       Procedure:  Send_Function_Key                                  *)
  10. (*                                                                      *)
  11. (*       Purpose:    Send function key definition                       *)
  12. (*                                                                      *)
  13. (*       Calling Sequence:                                              *)
  14. (*                                                                      *)
  15. (*           Send_Function_Key( Key_Text : AnyStr );                    *)
  16. (*                                                                      *)
  17. (*              Key_Text   --- text to be sent                          *)
  18. (*                                                                      *)
  19. (*       Remarks:                                                       *)
  20. (*                                                                      *)
  21. (*          If the string to be sent has not "Wait For" markers, then   *)
  22. (*          it is sent in its entirety in one call here.  If there ARE  *)
  23. (*          "Wait For" characters, then the flag WaitString_Mode is set *)
  24. (*          TRUE, Script_Wait_Text is set to the character to be found, *)
  25. (*          and  Script_Wait_Reply_Text is set to the remainder of the  *)
  26. (*          function key string.  This allows the terminal emulation to *)
  27. (*          properly process any received characters while PibTerm is   *)
  28. (*          waiting for the selected string to appear.                  *)
  29. (*                                                                      *)
  30. (*----------------------------------------------------------------------*)
  31.  
  32. VAR
  33.    I       : INTEGER;
  34.    L       : INTEGER;
  35.    Ch      : CHAR;
  36.    FK_Char : CHAR;
  37.    Done    : BOOLEAN;
  38.  
  39. BEGIN (* Send_Function_Key *)
  40.  
  41.    L      := LENGTH( Key_Text );
  42.    I      := 1;
  43.    Done   := FALSE;
  44.  
  45.    WHILE( I <= L ) AND ( NOT Done ) DO
  46.       BEGIN
  47.  
  48.          FK_Char := Key_Text[I];
  49.  
  50.          IF FK_Char = FK_CR THEN
  51.             Async_Send( CHR( CR ) )
  52.  
  53.          ELSE IF FK_Char = FK_Delay THEN
  54.             DELAY( One_Second_Delay )
  55.  
  56.          ELSE IF FK_Char = FK_Wait_For THEN
  57.             BEGIN   (* Wait For *)
  58.  
  59.                I := I + 1;
  60.  
  61.                IF ( I <= L ) THEN
  62.                   BEGIN
  63.                      WaitString_Mode        := TRUE;
  64.                      Really_Wait_String     := TRUE;
  65.                      Script_Wait_Text       := Key_Text[I];
  66.                      Script_Wait_Time       := 60;
  67.                      Script_Wait_Failure    := 0;
  68.                      Script_Wait_Start      := TimeOfDay;
  69.                      I                      := I + 1;
  70.                      IF ( I <= L ) THEN
  71.                         Script_Wait_Reply_Text := COPY( Key_Text, I, L - I + 1 )
  72.                      ELSE
  73.                         Script_Wait_Reply_Text := '';
  74.                      Done                      := TRUE;
  75.                   END;
  76.  
  77.             END
  78.          ELSE
  79.             Async_Send( Key_Text[I] );
  80.  
  81.          I := I + 1;
  82.  
  83.       END;
  84.  
  85. END   (* Send_Function_Key *);
  86.